home *** CD-ROM | disk | FTP | other *** search
Wrap
-- Net preloadNet Thing -- behavior library version 1.1 -- preloadNetThingBuddy Behavior script -- 2/13/97 Chris Walcott -- This behavior can be used to as a general purpose preloadNetThing script. -- The behavior is assigned to a frame Script. -- The required custom properties are: -- "Channel number of field" - this is the field that will contain the list -- of URL's that are to be preloaded. Use the Score channel number of the field. -- "Debug" - If TRUE, status lines will print to the message window. -- "AutoLoad URL" - If set to "AutoLoad", a preloadNetThing will be performed on -- the URL provided in the next property field. If set to "Manual", you will need -- to perform the gotoNetPage operation yourself. -- "Target URL" - if AutoLoad is set, a gotoNetPage operation will be performed -- on this URL. property pListURLs -- field containing URL's to preload property pDebug -- field containing URL's to preload property pAutoLoad -- field containing URL's to preload property pURL -- which URL is called if AutoLoad is set property pInitializeDone -- field containing URL's to preload property pWaitingList -- list of URL's waiting to be retrieved property pDispatchedListURL -- list of preloaded URL's property pDispatchedListNetID -- list of preloaded URL net ID's on getPropertyDescriptionList set description = [:] addprop description, #pListURLs, [#default: member 1, #format: #field, #comment: "Member name of URL list:"] addprop description, #pDebug, [#default: 0, #format:#boolean, #comment: "Debug:"] addprop description, #pAutoLoad, [#default: #AutoLoad, #format:#symbol, #comment: "AutoLoad URL:", #range: [#AutoLoad, #Manual]] addprop description, #pURL, [#default: "http://", #format: #string, #comment: "Target URL for AutoLoad:"] return description end on beginSprite me set pInitializeDone = FALSE end on exitFrame me if NOT pInitializeDone = TRUE then initializeNetList cursor 4 set pInitializeDone = TRUE end if if NetDoneList() > 0 then go to the frame else if pAutoLoad = TRUE then cursor 0 gotoNetPage pURL else go to frame "done" cursor 0 end if end if end on initializeNetList me -- initialize the lists set pWaitingList = [] set pDispatchedListURL = [] set pDispatchedListNetID = [] repeat with i = 1 to the lineCount of member pListURLs set theLine = line i of field pListURLs append( pWaitingList, theLine) end repeat if pDebug = TRUE then put "List of assets to preload" & RETURN & pWaitingList & RETURN end if end on netDoneList me -- check the dispatch list for assest that have arrived repeat with iListAsset = 1 to count( pDispatchedListURL ) -- if the asset has arrived if NetDone( getAt( pDispatchedListNetID, iListAsset ) ) then if pDebug = TRUE then put "Asset Received:" & getAt( pDispatchedListURL, iListAsset ) end if -- remove if from the dispatch list deleteAt pDispatchedListURL, iListAsset deleteAt pDispatchedListNetID, iListAsset end if end repeat -- check the dispatch and waiting list: how many things -- can we preload? Current stream limit is set to 4 set iCountDispatch to min( count( pWaitingList ), 4 - count( pDispatchedListURL ) ) repeat with iFreeSpot = 1 to iCountdispatch -- start the preloadNetThing operation on the next waiting asset set getMe = getAt( pWaitingList, 1 ) if pDebug = TRUE then put "Asset Preloading" getMe end if preloadNetThing getMe -- move the asset to the dispatched list append pDispatchedListURL, getAt( pWaitingList, 1 ) append pDispatchedListNetID, getLatestNetID() -- remove the asset from the waiting list deleteAt pWaitingList, 1 end repeat -- check the dispatch list for assest that have arrived set netDoneListCount = count( pDispatchedListURL ) + count( pWaitingList ) if pDebug = TRUE then put "Assets remaining to process:" netDoneLIstCount end if return netDoneListCount end on getBehaviorDescription return "Preloads a file from the internet to the disk cache so it can be used later without a download delay. Loads the file while the current movie continues playing. After an item is preloaded, it can be displayed immediately because it is taken from the local browserΓÇÖs cache rather than from the network. "& RETURN & "PARAMETERS:" & RETURN & "ΓÇó Channel Number of Field - this is the field that will contain the list" -- of URL's that are to be preloaded. Use the Score channel number of the field. -- "Debug" - If TRUE, status lines will print to the message window. -- "AutoLoad URL" - If set to "AutoLoad", a preloadNetThing will be performed on -- the URL provided in the next property field. If set to "Manual", you will need -- to perform the gotoNetPage operation yourself. -- "Target URL" - if AutoLoad is set, a gotoNetPage operation will be performed -- on this URL.